<template>
  <div id="demo">
    <button @click="jian">减</button>
    <button @click="jia">加</button>

    <transition name="test1" mode="out-in">
      <ul v-if="items.length">
        <li v-for="item in items" :key="item">这是 {{ item }}</li>
      </ul>
      <p v-else>Sorry, no items found.</p>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: true,
      items: [1],
    };
  },
  methods: {
    jia() {
      this.items.push(this.items.length + 1);
    },
    jian() {
      this.items.splice(this.items.length - 1, 1);
    },
  },
};
</script>

<style scoped>
.test1-enter-from,
.test1-enter-to {
  transform: translateX(50px);
  opacity: 0;
}
.test1-enter-active,
.test1-enter-active {
  transition: opacity 0.3s ease;
  animation: ani 0.5s;
}
</style>